<layout name="popup" />
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="1">
	<div class="popup-header">
		<h1>新增菜单</h1>
		<i class="mid"></i>
		<a class="btn btn-normal" onclick="save();">确定</a>
		<a class="btn btn-return" onclick="close_popup();">取消</a>
	</div>
	<div class="popup-body">
		<div class="popup-body-scroll">
			<div class="popup-content">
				<form id="form_data" name="form_data" method="post" class="weixin">
					<input type="hidden" name="ajax" id="ajax" value="1">
					<input type="hidden" name="opmode" id="opmode" value="add">
					<div class="box">
						<label class="input-label" for="name">菜单名称*：</label>
						<input class="input" type="text" id="name" name="name" check="required" info="请输入菜单名称">
					</div>
					<div class="box" style="margin-bottom: 0px;">
						<label class="input-label" for="val">事件选择*：</label>
						<select class="select" name="type"id="type">
							<option value="click">点击推事件</option>
							<option value="view">跳转URL</option>
							<option value="scancode_push">扫码推事件</option>
							<option value="scancode_waitmsg">扫码推事件且弹出“消息接收中”提示框</option>
							<option value="pic_sysphoto">弹出系统拍照发图</option>
							<option value="pic_photo_or_album">弹出拍照或者相册发图</option>
							<option value="location_select">弹出地理位置选择器</option>
							<option value="media_id">下发消息（除文本消息）</option>
							<option value="view_limited">跳转图文消息URL</option>
						</select>
						<i class="icon"></i>
					</div>
					<div class="box" style="height:21px;line-height: 21px;font-size: 14px;">
						<label class="input-label" for="val"></label>
						注：需要进行链接的事件为view事件
					</div>
					<div class="box" style="margin-bottom: 0px;">
						<label class="input-label" for="url">URL*：</label>
						<input class="input" type="text" id="url" name="url"  >
					</div>
					<div class="box" style="height:21px;line-height: 21px;font-size: 14px;">
						<label class="input-label" for="val"></label>
						示例：index.php?m=&c=Task&a=folder&fid=all
					</div>
					<div class="box" style="margin-bottom: 0px;">
						<label class="input-label" for="key">Key*：</label>
						<input class="input" type="text" id="key" name="key" >
					</div>
					<div class="box" style="height:21px;line-height: 21px;font-size: 14px;">
						<label class="input-label" for="val"></label>
						注：每个菜单需要有单独的key
					</div>
					<div class="box">
						<label class="input-label" for="pid_name">父级*：</label>
						<div class="input-box w19">
							<input name="pid" id="pid" type="hidden" info="请选择父级" check="required" />
							<input name="pid_name" class="input" id="pid_name" type="text" readonly="readonly" info="请选择父级" check="required"/>
							<span class="add-on w6" onclick="select_weixin_menu()" > 选择 </span>
						</div>
					</div>
					<div class="box">
						<label class="input-label" for="sort">排序：</label>
						<div class="input-block w10">
							<input class="input" type="text" id="sort" name="sort" >
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var fn = {
				save : function() {
					send_form('form_data', '{:url("save_weixin_menu")}', '', function(ret) {
						if (ret.status == 1) {
							parent.layer.msg(ret.info, {
								time : 1200
							}, function() {
								parent.layer.close(index);
								parent.location.reload(true);
							});
						} else {
							parent.layer.msg(ret.info);
							return false;
						};
					});
				},
				close_popup : function() {
					parent.layer.close(index);
				},
				select_weixin_menu : function() {
					winopen("{:url('select_weixin_menu')}", 560, 470);
				},
			};
			win_exp(fn);

			$pid = $("#pid", parent.document).val();
			$("#pid").val($pid);
		});

	</script>

</block>